
-- CALC_AIRSHIP_STRENGTHEN_COST
-- 计算飞船强化消耗

return function(id, info)
    local config = NewAirShipM.query(id);
    local map = ME.user.dbase:query("airships") or {};
    local num = 0;
    local scrapCost = 0;
    local ret = {};

    -- 宝石之翼消耗类型
    local stoneType = {
            ["fire"]  = 10007,
            ["armor"] = 10010,
            ["speed"] = 10009,
            ["luck"]  = 10008, 
        }
    local stoneMap = {0,1,1,2,2,3,4,5};

    for key, value in pairs(info) do
        -- 原始值
        num = config["init_"..key];

        -- 加上已提升值
        if map and map[id] and map[id][key] then
            num = num + map[id][key];
        end

        -- 有需要提升的值
        if value > 0 then
            -- 碎片消耗，级别 * 1000
            scrapCost = scrapCost + (num + num + value + 1) * value * 500;
            
            -- 宝石之翼消耗
            if stoneType[key] then
                local stoneCost = 0;
                for i = 1, value do
                    stoneCost = stoneCost + stoneMap[math.min(math.modf((num + i + 4) / 5), 8)]
                end
                if stoneCost > 0 then
                    ret[stoneType[key]] = stoneCost;
                end
            end
        end
    end

    local classId = SkyResourceM.queryByAlias("relic_scrap", "class_id");
    ret[classId] = scrapCost;
    return ret;
end